<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">

		<title>Preclinic - Medical & Hospital - Bootstrap 4 Admin Template</title>
		<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="assets/css/font-awesome.min.css">
		<link rel="stylesheet" type="text/css" href="assets/css/style.css">
		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.min.js"></script>
		<script src="assets/js/respond.min.js"></script>
	<![endif]-->
	</head>

	<body>
		<div class="main-wrapper account-wrapper">
			<div class="account-page">
				<div class="account-center">
					<div class="account-box">
						<form action="" class="form-signin">
							<div class="form-group">
								<label>请输入用户名或邮箱</label>
								<input type="text" autofocus required class="form-control" id="username">
							</div>
							<div class="form-group">
								<label>请输入密码</label>
								<input type="password" class="form-control" id="password">
							</div>
							<div class="form-group text-right">
								<a href="forgot-password.html">忘记密码?</a>
							</div>
							<div class="form-group text-center">
								<button onclick="login($('#username').val(), $('#password').val())"
									class="btn btn-primary account-btn" type="button">登录</button>
							</div>
							<div class="text-center register-link">
								没有拥有账户? <a href="register.html">现在开始注册</a>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<script src="assets/js/jquery-3.2.1.min.js"></script>
		<script src="assets/js/popper.min.js"></script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/app.js"></script>
		<script src="ajax.js"></script>
		<script>
			function postdata(url, paprem) {
				$.ajax({
					type: 'POST',
					dataType: 'json',
					url: 'http://localhost:8080' + url,
					contentType: "application/json",
					data: JSON.stringify(paprem),
					success: function(d) {
						// 写自己的内容
					}
				})
			}

			function login(username, password) {
				var paprem = {
					"operator": username,
					"password": password
				};
				$.ajax({
					type: 'POST',
					dataType: 'json',
					url: 'http://localhost:8080/back/user/login',
					contentType: "application/json",
					data: JSON.stringify(paprem),
					success: function(d) {
						console.log(d.code)
						if (d.code == '200') {
							url = "experience.html?id=" + d.data.id + "&level=" + d.data.level;
							console.log(url)
							window.location.href = url;
						}
					}
				})
			}
			$('#login').click(function() {
				login($('#username').val(), $('#password').val())
			})
		</script>
	</body>

</html>
